// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;

    @property
    text: string = 'hello';

    @property(cc.SpriteFrame)
    faceLeft: cc.SpriteFrame = null;

    
    @property(cc.SpriteFrame)
    faceRight: cc.SpriteFrame = null;

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        cc.log("move script is load");
    }

    //向左移动
    moveRight(){
        let sp : cc.Sprite = this.node.getComponent(cc.Sprite);
        sp.spriteFrame = this.faceRight;
        this.node.x += 10;
    }

    //向左移动
    moveLeft(){
        //改变当前 节点的 图片
        let sp : cc.Sprite = this.node.getComponent(cc.Sprite);
        sp.spriteFrame = this.faceLeft;

        this.node.x -= 10;
    }

    start () {

    }

    // update (dt) {}
}
